<template>
     <el-select v-model="defaultDictValue" :disabled="disabledFlag"   @change="handleChange" clearable placeholder="请选择" style="width:100%;">
            <el-option
              v-for="item in list"
              :key="item.dictValue"
              :label="item.dictName"
              :value="item.dictValue"/>
    </el-select>
</template>


<script>
import { listDict ,findByDictTypeName} from '@/api/dict'

export default {
  name: 'add',
  // 接受父组件的值
  props: {
     dictType: undefined,
     dictValue: 0,
     disabledFlag: false,
    },
  data() {
    return {
      list: undefined,
      defaultDictValue: this.dictValue,
      // dictValue1: undefined,
       search: {
        params: {
          id: '',
          name: '',
          displayName: '',
          email: '',
          phone: '',
          position: '',
          deptName: '',
          createTime: '',
        },
       }
    }
  },
  watch: {
    "dictValue":function(val){
      this.defaultDictValue = val
    }
  },
  created() {
    this.getList()

  },
  methods: {
       getList() {
         findByDictTypeName(this.dictType)
        .then(response => {
          this.list = response.data
        })
        .catch(() => {
          this.list = []
        })
    },
    handleChange(val) {
        console.log(val);
        this.$emit("dictValue",val)
      },
    stepChange(currentStep){
        this.currentStep = currentStep;
    }
  }
}
</script>

<style scoped>
.parentColl >>> .el-collapse-item__header{
  min-height: 95px;
  font-size: 20px;
  font-weight: 1000;
  padding:20px;
}
</style>
